home *** CD-ROM | disk | FTP | other *** search
- Path: dispatch.news.demon.net!demon!vecnet
- From: gspencer@vecnet.demon.co.uk (Gary K. Spencer)
- Newsgroups: comp.lang.c++
- Subject: Re: templates on VAX/VMS
- Date: Wed, 28 Feb 1996 08:41:55 GMT
- Organization: Vector Networks Limited
- Message-ID: <825496915.10116@vecnet.demon.co.uk>
- References: <gastineau-2502961624010001@dialupline64.ghgcorp.com>
- NNTP-Posting-Host: vecnet.demon.co.uk
- X-NNTP-Posting-Host: vecnet.demon.co.uk
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <gastineau-2502961624010001@dialupline64.ghgcorp.com>,
- gastineau@ghgcorp.com (Brian Gastineau) wrote:
- >I am trying to implement a linked list template out of the "C++ How to
- >Program" textbook by Deitel & Deitel, 1994, page 697, on a VAX.
- >
- >The node template class is of the form:
- >
- > template<class NODETYPE>
- > class ListNode {
- > friend class List<NODETYPE>;
- > public:
- > ListNode(const NODETYPE &);
- > NODETYPE getData() const;
- > private:
- > NODETYPE data;
- > ListNode *nextPtr;
- > };
- >
- >The list template class is of the form:
- >
- > template<class NODETYPE>
- > class List {
- > public:
- > List();
- > ~List();
- > void insertAtFront(const NODETYPE &);
- > void insertAtBack(const NODETYPE &);
- > int removeFromFront(NODETYPE &);
- > int removeFromBack(NODETYPE &);
- > int isEmpty() const;
- > void print() const;
- > private:
- > ListNode<NODETYPE> *firstPtr;
- > ListNode<NODETYPE> *lastPtr;
- > ListNode<NODETYPE> *getNewNode(const NODETYPE &);
- > };
- >
- >All of the object function declaration have a related function body
- >included in the same file. I've got some subroutines in other files that
- >are compiling and linking OK, so I don't think that the problem lies with
- >not including the files in the right way
- >
- >The driver uses the templates in the following lines:
- >
- > List<int> integerList;
- > List<float> floatList;
- >
- >The code compiles OK, but during linking, the following errors are given:
- >
- > $ link driver
- > %LINK-W-NUDFSYMS, 14 undefined symbols:
- > %LINK-I-UDFSYM, INSERTATBACK__8LIST___FXNKF
-
- You need to use :-
- #pragma define_template List<int>
- #pragma define_template List<float>
-
- in one of your source modules to get the compiler to generate the code for the
- template class. I think there is a command line switch that does the same
- thing, but I use the above method.
-
- Regards
-
- Gary K. Spencer
- Vector Networks Limited
-
-
-